package com.konke.sdslibrary.factroy;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.konke.sdslibrary.HostContext;
import com.konke.sdslibrary.SmartHomeApi;
import com.konke.sdslibrary.model.UniformDeviceType;
import com.sds.sdk.android.sh.common.SHClientState;
import com.sds.sdk.android.sh.common.SHDeviceRealType;
import com.sds.sdk.android.sh.common.SHDeviceSubType;
import com.sds.sdk.android.sh.common.SHDeviceType;
import com.sds.sdk.android.sh.common.SHGuardSensorType;
import com.sds.sdk.android.sh.internal.request.ChopinFreshAirConfigArgsResult;
import com.sds.sdk.android.sh.internal.request.FancoilConfigArgsResult;
import com.sds.sdk.android.sh.internal.request.FloorheatingConfigArgResult;
import com.sds.sdk.android.sh.internal.request.GetFreshAirStatusResult;
import com.sds.sdk.android.sh.model.Action;
import com.sds.sdk.android.sh.model.AddCodeLibResult;
import com.sds.sdk.android.sh.model.AddCodedLockUserResult;
import com.sds.sdk.android.sh.model.AddSceneResult;
import com.sds.sdk.android.sh.model.AirBoxNodeArgResult;
import com.sds.sdk.android.sh.model.ArmingState;
import com.sds.sdk.android.sh.model.CnwiseMusicControllerStatus;
import com.sds.sdk.android.sh.model.CodeLibBaseResult;
import com.sds.sdk.android.sh.model.CodeLibBindResult;
import com.sds.sdk.android.sh.model.CodeLibTaskResult;
import com.sds.sdk.android.sh.model.Condition;
import com.sds.sdk.android.sh.model.Controller;
import com.sds.sdk.android.sh.model.Device;
import com.sds.sdk.android.sh.model.DeviceOnlineState;
import com.sds.sdk.android.sh.model.FancoilSmartModel;
import com.sds.sdk.android.sh.model.Gateway;
import com.sds.sdk.android.sh.model.GetAirBoxDayStatisitcResult;
import com.sds.sdk.android.sh.model.GetAirBoxStateResult;
import com.sds.sdk.android.sh.model.GetAirSwitchStatusResult;
import com.sds.sdk.android.sh.model.GetCcuInfoResult;
import com.sds.sdk.android.sh.model.GetCcuVersionResult;
import com.sds.sdk.android.sh.model.GetCodedLockUserInfoResult;
import com.sds.sdk.android.sh.model.GetCodelibButtonsResult;
import com.sds.sdk.android.sh.model.GetCodelibResult;
import com.sds.sdk.android.sh.model.GetDayPowerResult;
import com.sds.sdk.android.sh.model.GetDevDetectedPowerResult;
import com.sds.sdk.android.sh.model.GetDevHwInfoResult;
import com.sds.sdk.android.sh.model.GetDevInfoResult;
import com.sds.sdk.android.sh.model.GetDimmableLightConfigResult;
import com.sds.sdk.android.sh.model.GetElectricalClearingDateResult;
import com.sds.sdk.android.sh.model.GetElectricalClearingInfoResult;
import com.sds.sdk.android.sh.model.GetElectricalEnergyArgsResult;
import com.sds.sdk.android.sh.model.GetElectricalEnergyValueResult;
import com.sds.sdk.android.sh.model.GetElectricalSwitchStatusResult;
import com.sds.sdk.android.sh.model.GetFancoilSmartModelResult;
import com.sds.sdk.android.sh.model.GetFancoilSystemStatusResult;
import com.sds.sdk.android.sh.model.GetFloorheatingStatusResult;
import com.sds.sdk.android.sh.model.GetGwWhitelistResult;
import com.sds.sdk.android.sh.model.GetGwWorkmodeResult;
import com.sds.sdk.android.sh.model.GetHomebridgeStatusResult;
import com.sds.sdk.android.sh.model.GetInfraredLastSendCodeResult;
import com.sds.sdk.android.sh.model.GetLocalCodelibsResult;
import com.sds.sdk.android.sh.model.GetLockOpenRecordResult;
import com.sds.sdk.android.sh.model.GetLockUserListResult;
import com.sds.sdk.android.sh.model.GetMonthPowerResult;
import com.sds.sdk.android.sh.model.GetMusicControllerStatusResult;
import com.sds.sdk.android.sh.model.GetMusicListResult;
import com.sds.sdk.android.sh.model.GetSocketRunArgsResult;
import com.sds.sdk.android.sh.model.GetYearPowerResult;
import com.sds.sdk.android.sh.model.GetYouzhuanMusicListResult;
import com.sds.sdk.android.sh.model.GetZbDevOnlineSwitchResult;
import com.sds.sdk.android.sh.model.GetZigbeeDevPingResult;
import com.sds.sdk.android.sh.model.Group;
import com.sds.sdk.android.sh.model.IFTTT;
import com.sds.sdk.android.sh.model.IFTTTEX;
import com.sds.sdk.android.sh.model.Limit;
import com.sds.sdk.android.sh.model.MotorOpt;
import com.sds.sdk.android.sh.model.PrepareTestCodeLibResult;
import com.sds.sdk.android.sh.model.Room;
import com.sds.sdk.android.sh.model.Scene;
import com.sds.sdk.android.sh.model.ShortcutPanelConfig;
import com.sds.sdk.android.sh.model.TextIndicatorResult;
import com.sds.sdk.android.sh.model.VoidResult;
import com.sds.sdk.android.sh.model.WhiteDev;
import com.sds.sdk.android.sh.model.ZigbeeFanCoilStatus;
import com.sds.sdk.android.sh.model.ZigbeeFloorHeatingStatus;
import com.sds.sdk.android.sh.model.ZigbeeFreshAirStatus;
import com.zsj.comminlibrary.util.log.XLog;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by L on 2016/6/29.
 */
public class HostManager implements HostContext {


    private SmartHomeApi smartHomeApi;

    public HostManager(SmartHomeApi smartHomeApi) {
        this.smartHomeApi = smartHomeApi;
    }

    @Override
    public void reconect(int delay) {
        smartHomeApi.reconect(delay);
    }

    @Override
    public boolean syncHostData() {
        return smartHomeApi.sycnData();
    }

    @Override
    public List<Device> findNewDevice() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryNewDevice();
        }
        return new ArrayList<>();
    }

    @Override
    public List<Device> findNewDeviceByType(UniformDeviceType deviceType) {
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        if (smartHomeApi == null) {
            return new ArrayList<>();  //#13277 java .lang.NullPointerException
        }
        return smartHomeApi.queryNewDevice(type);
    }

    @Override
    public List<Device> findDeviceByType(UniformDeviceType deviceType) {
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        if (smartHomeApi == null) {
            return new ArrayList<>();
        }
        return smartHomeApi.queryDevice(type, SHDeviceSubType.parseValue(deviceType.name()));
    }

    @Override
    public Device findDeviceById(int id, UniformDeviceType deviceType) {  //  #6605 java.lang.NullPointerException
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        if (smartHomeApi != null) {
            return smartHomeApi.loadDevice(id, type);
        }
        return null;
    }

    @Override
    public Device findDeviceById(String id, UniformDeviceType deviceType) {
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        if (smartHomeApi != null) {
            return smartHomeApi.loadDevice(id, type);
        }
        return null;
    }

    @Override
    public Device findDeviceById(int id, SHDeviceType deviceType) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.loadDevice(id, deviceType);
    }

    @Override
    public SHDeviceRealType findDeviceRealType(int id, UniformDeviceType deviceType) {
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        if (smartHomeApi != null) {
            return smartHomeApi.loadDeviceRealType(id, type);
        }  //SHDeviceRealType
        return SHDeviceRealType.UNKOWN;
    }

    @Override
    public List<Device> findZigbeeSocket(SHDeviceType shDeviceType) {
        List<Device> deviceList = smartHomeApi.queryZigbeeDevices();
        if (deviceList != null && !deviceList.isEmpty()) {
            List<Device> socketList = new ArrayList<>();
            for (Device device : deviceList) {
                if (device.getType() == SHDeviceType.ZIGBEE_Outlet) {
                    socketList.add(device);
                }
            }

            return socketList;
        }
        return null;
    }

    @Override
    public Device findZigbeeDeviceById(int id) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryZigbeeDevice(id);
        }
        return null;
    }

    @Override
    public DeviceOnlineState findZigbeeDeviceOnlineState(String mac) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.findZigbeeDeviceOnlineState(mac);
    }

    @Override
    public Scene findSceneById(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.loadScene(id);
    }

    @Override
    public Scene findSceneWithPanel(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.findSceneWithPanel(id);
    }

    @Override
    public Group findGroupById(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.loadGroup(id);
    }

    @Override
    public IFTTT findRuleById(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.loadRule(id);
    }

    @Override
    public IFTTTEX findExRuleById(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.loadExRule(id);
    }


    @Override
    public VoidResult deleteAlarmMsg(String key) {
        if (smartHomeApi != null) {
            return smartHomeApi.deleteAlarmMsg(key);
        }
        return null;
    }


    @Override
    public GetCcuVersionResult queryCcuVersion() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryCcuVersion();
        }
        return null;
    }

    @Override
    public GetCcuInfoResult queryCcuInfo() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryCcuInfo();
        }
        return null;
    }

    @Override
    public GetDevInfoResult queryDevInfo(int id) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryZigbeeDeviceInfo(id);
        }
        return null;
    }

    @Override
    public CnwiseMusicControllerStatus queryCnwiseStatus(int id) {
        if (smartHomeApi != null) {
            GetMusicControllerStatusResult statusResult = smartHomeApi.queryMusicStatus(id);
            if (statusResult != null)
                return statusResult.getMusicControllerStatus();
        }
        return null;
    }

    @Override
    public List<GetMusicListResult.MusicListBean> queryCnwiseMusicList(int id) {
        if (smartHomeApi != null) {
            GetMusicListResult listResult = smartHomeApi.queryMusicList(id);
            if (listResult != null)
                return listResult.getMusicList();
        }
        return null;
    }

    @Override
    public List<GetDayPowerResult.RecordsBean> queryPowerByDay(int id, String start, String end) {
        if (smartHomeApi != null) {
            GetDayPowerResult listResult = smartHomeApi.queryPowerByDay(id, start, end);
            if (listResult != null)
                return listResult.getRecords();
        }
        return null;
    }

    @Override
    public List<GetMonthPowerResult.RecordsBean> queryPowerByMonth(int id, String start, String end) {
        if (smartHomeApi != null) {
            GetMonthPowerResult listResult = smartHomeApi.queryPowerByMonth(id, start, end);
            if (listResult != null) {
                return listResult.getRecords();
            }
        }
        return null;
    }

    @Override
    public List<GetYearPowerResult.RecordsBean> queryPowerByYear(int id, String start, String end) {
        if (smartHomeApi != null) {
            GetYearPowerResult listResult = smartHomeApi.queryPowerByYear(id, start, end);
            if (listResult != null)
                return listResult.getRecords();
        }
        return null;
    }

    @Override
    public String queryDevPower(int id) {
        if (smartHomeApi != null) {
            String power = smartHomeApi.queryDevicePowerById(id);
            if (power != null)
                return power;
        }
        return null;
    }


    @Override
    public boolean upgradeKitCcu(String url) {
        if (smartHomeApi != null) {
            return smartHomeApi.upgradeKitCcu(url);
        }
        return false;
    }

    @Override
    public void tryLan() {
        if (smartHomeApi != null) {
            smartHomeApi.lanCon();
        }
    }

    @Override
    public void cancelWarning() {
        if (smartHomeApi != null) {
            smartHomeApi.cancelWarning();
        }
    }

    @Override
    public void readAlarm(String key) {
        if (smartHomeApi != null) {
            smartHomeApi.readAlarmMsg(key);
        }
    }

    @Override
    public void readAlarm(String startTime, String endTime) {
        if (smartHomeApi != null) {
            smartHomeApi.readAlarm(startTime, endTime);
        }
    }

    @Override
    public void clearSosAlarm(int id) {
        if (smartHomeApi != null) {
            smartHomeApi.clearSosAlarm(id);
        }
    }

    @Override
    public boolean setRoomDnd(int roomId, boolean on) {
        if (smartHomeApi != null) {
            return smartHomeApi.setRoomDnd(roomId, on);
        }
        return false;
    }

    @Override
    public VoidResult restoreCcu(String fromCcuId, String url) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.restoreCcu(fromCcuId, url);
    }

    @Override
    public VoidResult backupCcu() {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.backupCcu();
    }

    @Override
    public GetZigbeeDevPingResult pingZigbeeDev(int gwId, String[] devMacs) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.pingZigbeeDev(gwId, devMacs);
    }

    @Override
    public VoidResult switchHomebridge(String id, boolean on) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.switchHomebridge(id, on);
    }

    @Override
    public GetHomebridgeStatusResult getHomebridgeStatus(String id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getHomebridgeStatus(id);
    }

    @Override
    public GetDevHwInfoResult getDevicesHwInfo(String[] macs) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getDevicesHwInfo(macs);
    }

    @Override
    public String getZigbeeDevHwVersion(String mac) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getZigbeeDevHwVersion(mac);
    }

    @Override
    public Gateway findGetewayInfo(String mac) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.findGetewayInfo(mac);
    }

    @Override
    public VoidResult resetGwFouctoryMode(int gwId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.resetGwFouctoryMode(gwId);
    }



    @Override
    public ArmingState queryCcuArmingState() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryArmingStatus();
        }
        return null;
    }

    @Override
    public List<Integer> getCustomGuardZones() {
        if (smartHomeApi != null) {
            int[] array = smartHomeApi.getCustomGuardZones();
            if (array != null) {
                List<Integer> zones = new ArrayList<>();
                for (int id : array) {
                    zones.add(id);
                }
                return zones;
            }
        }
        return null;
    }

    @Override
    public boolean setCustomZoneGuard(int[] roomIds) {
        if (smartHomeApi != null) {
            return smartHomeApi.setCustomZoneGuard(roomIds);
        }
        return false;
    }

    @Override
    public int getSecurityLeaveHomeDelay() {
        if (smartHomeApi != null) {
            return smartHomeApi.getSecurityLeaveHomeDelay();
        }
        return 0;
    }

    @Override
    public boolean setSecurityLeaveHomeDelay(int delay) {
        if (smartHomeApi != null) {
            return smartHomeApi.setSecurityLeaveHomeDelay(delay);
        }
        return false;
    }

    @Override
    public boolean setSecurityState(ArmingState armingState) {
        if (smartHomeApi != null) {
            return smartHomeApi.setSecurityLeaveHomeDelay(armingState);
        }
        return false;
    }

    @Override
    public String getCurCcuVersion() {
        if (smartHomeApi != null) {
            return smartHomeApi.getCurCcuVersion();
        }
        return null;
    }

    @Override
    public SHClientState queryHostState() {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getCurrentState();
    }


    @Override
    public List<Room> findAllRoom() {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.queryAllRooms();
    }

    @Override
    public List<Device> findDeviceInGw(String gwmac) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryDevice(gwmac);
        }
        return null;
    }

    @Override
    public List<Device> findDeviceByMac(String mac) {
        if (smartHomeApi != null) {
            return smartHomeApi.findDeviceByMac(mac);
        }
        return null;
    }

    @Override
    public int findZigbeeDeviceProductId(String mac) {
        if (smartHomeApi != null) {
            return smartHomeApi.findZigbeeDeviceProductId(mac);
        }
        return -1;
    }

    @Override
    public List<Device> findDeviceInGw(int roomId, String gwmac) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryDevice(roomId, gwmac);
        }
        return null;
    }

    @Override
    public List<Device> findDeviceInRoom(int roomId) {

        if (smartHomeApi != null) {
            return smartHomeApi.queryDevice(roomId);
        }
        return null;
    }

    @Override
    public List<Device> findDeviceInRoom(int roomId, UniformDeviceType deviceType) {
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        if (smartHomeApi != null) {
            return smartHomeApi.queryDevice(roomId, type);
        }
        return null;
    }

    @Override
    public List<Scene> findSceneInRoom(int roomId) {

        if (smartHomeApi != null) {
            return smartHomeApi.queryScene(roomId);
        }
        return null;
    }

    @Override
    public List<Group> findGroupList() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryGroup();
        }
        return null;
    }

    @Override
    public List<IFTTT> findIftttRules() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryIfttt();
        }
        return null;
    }

    @Override
    public List<IFTTTEX> findIftttExRules() {
        if (smartHomeApi != null) {
            return smartHomeApi.queryIftttEx();
        }
        return null;
    }

    @Override
    public Controller findController(int id) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryController(id);
        }
        return null;
    }

    @Override
    public int queryOnLightCount(List<Device> devices) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryOnLightCount(devices);
        }
        return 0;
    }

    @Override
    public int queryOpenCurtainCount(List<Device> devices) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryOpenCurtainCount(devices);
        }
        return 0;
    }

    @Override
    public double queryAvgTemp(List<Device> devices) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryAvgTemp(devices);
        }
        return 0;
    }

    @Override
    public double queryAvgHumi(List<Device> devices) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryAvgHumi(devices);
        }
        return 0;
    }

    @Override
    public boolean doorIsOpen(List<Device> devices) {
        if (smartHomeApi != null) {
            return smartHomeApi.doorIsOpen(devices);
        }
        return false;
    }

    @Override
    public boolean hasPerseon(List<Device> devices) {
        if (smartHomeApi != null) {
            return smartHomeApi.hasPerseon(devices);
        }
        return false;
    }

    @Override
    public SHGuardSensorType findGuardSensorType(int id) {
        if (smartHomeApi != null) {
            return smartHomeApi.queryGuardSensorType(id);
        }
        return null;
    }

    @Override
    public GetLockUserListResult getLockUserList(int devId) {
        if (smartHomeApi != null) {
            return smartHomeApi.asyncLockUserList(devId);
        }
        return null;
    }

    @Override
    public GetLockOpenRecordResult getLockOpenRecordList(int id, int pageIdx, int pageSize, String beginDay, String endDay) {
        if (smartHomeApi != null) {
            return smartHomeApi.asyncLockOpenRecordList(id, pageIdx, pageSize, beginDay, endDay);
        }
        return null;
    }

    @Override
    public GetInfraredLastSendCodeResult getInfraredGetLastSendCode(int devId) {
        if (smartHomeApi != null) {
            return smartHomeApi.getInfraredGetLastSendCode(devId);
        }
        return null;
    }

    @Override
    public GetGwWorkmodeResult getGwWorkmode(int gwId) {
        if (smartHomeApi != null) {
            return smartHomeApi.getGwWorkmode(gwId);
        }
        return null;
    }

    @Override
    public VoidResult setGwWorkmode(int gwId, int workMode) {
        if (smartHomeApi != null)
            return smartHomeApi.setGwWorkmode(gwId, workMode);
        return null;
    }

    @Override
    public GetGwWhitelistResult getGwWhitelist(int gwId) {
        if (smartHomeApi != null) {
            return smartHomeApi.getGwWhitelist(gwId);
        }
        return null;
    }

    @Override
    public VoidResult addGwWhiteList(int gwId, List<WhiteDev> devList) {
        if (smartHomeApi != null) {
            return smartHomeApi.addGwWhiteList(gwId, devList);
        }
        return null;
    }

    @Override
    public VoidResult delGwWhiteList(int gwId, String[] devMacs) {
        if (smartHomeApi != null) {
            return smartHomeApi.delGwWhiteList(gwId, devMacs);
        }
        return null;
    }

    @Override
    public List<Device> findZigbeeDevicesByLast4Mac(String lastMac) {
        if (smartHomeApi != null) {
            return smartHomeApi.findZigbeeDevicesByLast4Mac(lastMac);
        }
        return null;
    }

    @Override
    public List<Device> findDevicesByName(String devName) {
        if (smartHomeApi != null) {
            return smartHomeApi.findDevicesByName(devName);
        }
        return null;
    }

    @Override
    public void searchIPC() {
        if (smartHomeApi != null)
            smartHomeApi.searchIPC();
    }

    @Override
    public AddSceneResult addScene(String sceneType, String sceneImange, String name, int roomId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.addScene(sceneType, sceneImange, name, roomId);
    }

    @Override
    public Scene editScene(int id, String sceneType, String sceneImange, String name, int roomId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.editScene(id, sceneType, sceneImange, name, roomId);
    }

    @Override
    public boolean setSceneTimer(int id, boolean enableTimer, String timer, List<String> week) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setSceneTimer(id, enableTimer, timer, week);
    }

    @Override
    public boolean setSceneAction(int id, List<Action> actionList) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setSceneAction(id, actionList);
    }

    @Override
    public Group editGroup(int id, String name, List<String> deviceId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.editGroup(id, name, deviceId);
    }

    @Override
    public IFTTT addIFttt(String name, int roomId, boolean notificationEnable, boolean ruleEnable, List<Condition> conditionList, List<Action> actionList) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.addIFttt(name, roomId, notificationEnable, ruleEnable, conditionList, actionList);
    }

    @Override
    public IFTTT editIFttt(int id, String name, int roomId, boolean notificationEnable, boolean ruleEnable, List<Condition> conditionList, List<Action> actionList) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.editIFttt(id, name, roomId, notificationEnable, ruleEnable, conditionList, actionList);
    }

    @Override
    public IFTTTEX addIFtttEx(String name, int roomId, boolean notificationEnable, boolean ruleEnable, List<Condition> conditionList, List<Limit> limitList, List<Action> actionList) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.addIFtttEx(name, roomId, notificationEnable, ruleEnable, conditionList, limitList, actionList);
    }

    @Override
    public IFTTTEX editIFtttEx(int id, String name, int roomId, boolean notificationEnable, boolean ruleEnable, List<Condition> conditionList, List<Limit> limitList, List<Action> actionList) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.editIFtttEx(id, name, roomId, notificationEnable, ruleEnable, conditionList, limitList, actionList);
    }

    @Override
    public boolean enableIfttt(int id, boolean enable) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.enableIfttt(id, enable);
    }

    @Override
    public boolean enableIftttEx(int id, boolean enable) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.enableIftttEx(id, enable);
    }


    @Override
    public boolean editGwName(int gwId, String gwName) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setGwName(gwId, gwName);
    }

    @Override
    public boolean editLockUser(int id, int userId, int openType, String nickName) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.asyncEditLockUser(id, userId, openType, nickName);
    }

    @Override
    public boolean editLockPassword(int id, String oldpwd, String newpwd) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.editLockPassword(id, oldpwd, newpwd);
    }

    @Override
    public boolean delGw(int gwId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.delGateway(gwId);
    }

    @Override
    public boolean upgradeGw(int gwId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.upgradeGateway(gwId);
    }

    @Override
    public boolean upgradeGw9531(int gwId,String url) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.upgradeGateway9531(gwId, url);
    }

    @Override
    public GetZbDevOnlineSwitchResult getZbDevSwitchStatus(int gwId) {
        if (smartHomeApi != null) {
          return   smartHomeApi.getZbDevSwitchStatus(gwId);
        }
        return null;
    }

    @Override
    public VoidResult setZbDevOnlineSwitch(int gwId, String arg) {
        if (smartHomeApi != null) {
          return   smartHomeApi.setZbDevSwitchStatus(gwId,arg);
        }
        return null;
    }

    @Override
    public boolean delGroup(int gid) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.delGroup(gid);
    }

    @Override
    public boolean delIFttt(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.delIFttt(id);
    }

    @Override
    public boolean delIFtttEx(int ruleId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.delIFtttEx(ruleId);
    }

    @Override
    public boolean delRoom(int roomId) {
        if (smartHomeApi == null) {
            return false;
        }
        List<Device> devices = smartHomeApi.queryDevice(roomId);
        if (devices != null && !devices.isEmpty()) {
            XLog.w("can't delete room in [" + roomId + "],still has " + devices.size() + " devices!");
            return false;
        }
        return smartHomeApi.delRoom(roomId);
    }

    @Override
    public boolean delDevice(int deviceId, String mac, UniformDeviceType deviceType) {
        if (smartHomeApi == null) {
            return false;
        }
        if (deviceType == UniformDeviceType.NET_KonkeSocket)
            return smartHomeApi.deleteKSocket(deviceId);
        else if (deviceType == UniformDeviceType.NET_KonkeLight)
            return smartHomeApi.deleteKLight(deviceId);
        else if (deviceType == UniformDeviceType.NET_KonkeAircleaner)
            return smartHomeApi.deleteKonkeAircleaner(deviceId);
        else if (deviceType == UniformDeviceType.NET_KonkeHumidifier)
            return smartHomeApi.deleteKonkeHumidifier(deviceId);
        else if (deviceType == UniformDeviceType.NET_HueLight)
            return smartHomeApi.deleteHueLight(deviceId);
        else if (deviceType == UniformDeviceType.NET_CnwiseMusicController)
            return smartHomeApi.deleteMusicController(deviceId);
        else if (deviceType == UniformDeviceType.NET_JuFengIpc)
            return smartHomeApi.deleteJufengIPC(deviceId);
        else if (deviceType == UniformDeviceType.VIRTUAL_SCENE)
            return smartHomeApi.deleteScene(deviceId);
        else if (deviceType == UniformDeviceType.NET_DaikinIndoorUnit)
            return smartHomeApi.asyncDelDaikinIndoorUnit(deviceId);
        else if (deviceType == UniformDeviceType.NET_ModBusDevice)
            return smartHomeApi.asyncDelModbus(deviceId);
        else if (deviceType == UniformDeviceType.NET_CENTRAL_AC_Gateway)
            return smartHomeApi.asyncDelCenralAcGw(deviceId);
        else if (deviceType == UniformDeviceType.ZIGBEE_AirSwitch) {
            return smartHomeApi.delAirSwitch(deviceId);
        } else if (deviceType == UniformDeviceType.NET_YouzhuanMusicController) {
            VoidResult result = smartHomeApi.delYouzhuanMusic(deviceId);
            return result != null && result.isSuccess();
        } else if (deviceType ==  UniformDeviceType.ZIGBEE_FloorHeatingDev){
            VoidResult result = smartHomeApi.delFloorheatingDev(deviceId);
            return result != null && result.isSuccess();
        } else if (deviceType == UniformDeviceType.ZIGBEE_FreshAirDev) {
            VoidResult result = smartHomeApi.delFreshAirDev(deviceId);
            return result != null && result.isSuccess();
        }else if (deviceType == UniformDeviceType.NET_AIR_BOX) {
            VoidResult result = smartHomeApi.delAirBoxDev(deviceId);
            return result != null && result.isSuccess();
        }
        return smartHomeApi.deleteDevice(mac);
    }

    @Override
    public boolean delScene(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.deleteScene(id);
    }

    @Override
    public boolean recycleDevice(int deviceId, UniformDeviceType deviceType) {
        if (smartHomeApi == null) {
            return false;
        }
        Device device;
        if (deviceType == UniformDeviceType.NET_KonkeSocket)
            device = smartHomeApi.editKSocket(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_KonkeLight)
            device = smartHomeApi.editKLight(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_KonkeHumidifier)
            device = smartHomeApi.editKonkeHumidifier(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_KonkeAircleaner)
            device = smartHomeApi.editKonkeAircleaner(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_HueLight)
            device = smartHomeApi.editHueLight(deviceId, "", "", -1);
        else if (deviceType == UniformDeviceType.NET_CnwiseMusicController)
            device = smartHomeApi.editMusicController(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_YouzhuanMusicController)
            device = smartHomeApi.editYouzhuanMusic(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_JuFengIpc)
            device = smartHomeApi.editJufengIPC(deviceId, "", -1);
        else if (deviceType == UniformDeviceType.NET_DaikinIndoorUnit)
            device = smartHomeApi.asyncEditDaikinIndoorUnit(deviceId, -1, "");
        else if (deviceType == UniformDeviceType.NET_CENTRAL_AC_IndoorUnit)
            device = smartHomeApi.asyncEditCentralAcIndoorUnit(deviceId, -1, "");
        else if (deviceType == UniformDeviceType.NET_ModBusDevice)
            device = smartHomeApi.asyncEditModbus(deviceId, -1, "");
        else if (deviceType == UniformDeviceType.NET_CENTRAL_AC_Gateway)
            device = smartHomeApi.asyncEditCentralAcGw(deviceId, -1, "");
        else if (deviceType == UniformDeviceType.NET_AIR_BOX)
            device = smartHomeApi.setAirBox(deviceId, "",-1 );
        else {
            SHDeviceType shDevice = SHDeviceType.parseValue(deviceType.name());
            if (shDevice == SHDeviceType.UNKOWN)
                shDevice = SHDeviceSubType.valueOf(deviceType.name()).getParentType();
            device = smartHomeApi.editDevice(shDevice, deviceId, -1, "", "");
        }

        return device != null;
    }


    @Override
    public boolean setShortcutPanelAction(int id, List<ShortcutPanelConfig> configList) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.asyncSetShortcutPanelAction(id, configList);
    }

    @Override
    public void activeShortcutPanel(int id, int buttonId) {
        if (smartHomeApi != null)
            smartHomeApi.asyncActiveShortcutPanel(id, buttonId);
    }

    @Override
    public boolean bindScene(int deviceId, int sceneId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.asyncBindScene(deviceId, sceneId);
    }

    @Override
    public Device editModbus(int id, int roomId, String name) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.asyncEditModbus(id, roomId, name);
    }

    @Override
    public Device editCentralAcGw(int id, int roomId, String name) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.asyncEditCentralAcGw(id, roomId, name);
    }


    @Override
    public VoidResult replaceDevice(String newDevMac, String oldDevMac, String gwMac) {

        if (smartHomeApi != null) {
            return smartHomeApi.replaceDevice(newDevMac, oldDevMac, gwMac);
        }
        return null;
    }

    @Override
    public boolean inShortCutPanel(int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.inShortCutPanel(nodeId);
    }

    @Override
    public boolean inController(int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.inController(nodeId);
    }

    @Override
    public boolean inLock(int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.inLock(nodeId);
    }

    @Override
    public boolean isBindWithLock(int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        return false;
    }

    @Override
    public boolean inGroup(int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.inGroup(nodeId);
    }

    @Override
    public List<Group> findGroupsByDeviceId(int nodeId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.findGroupsByDeviceId(nodeId);
    }

    @Override
    public boolean inScene(UniformDeviceType deviceType, int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        if (deviceType == null) {  // #10475 java.lang.NullPointerException
            return false;
        }
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        return smartHomeApi.inScene(type, nodeId);
    }

    @Override
    public boolean inIFTTT(UniformDeviceType deviceType, int nodeId) {
        if (smartHomeApi == null) {
            return false;
        }
        if (deviceType == null) {  //#17073 java.lang.NullPointerException
            return false;
        }
        SHDeviceType type = SHDeviceType.parseValue(deviceType.name());
        if (type.equals(SHDeviceType.UNKOWN)) {
            type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
        }
        return smartHomeApi.inIFTTT(type, nodeId);
    }

    @Override
    public boolean openGateway(int gwId) {
        if (smartHomeApi != null) {
            return smartHomeApi.openGatewayChannel(gwId);
        }
        return false;
    }

    @Override
    public boolean closeGateway(int gwId) {
        if (smartHomeApi != null) {
            return smartHomeApi.closeGatewayChannel(gwId);
        }
        return false;
    }


    @Override
    public boolean optDaikinIndoorUnit(int id, boolean on, String runModel, String speed, int temp) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.asyncOptDaikinIndoorUnit(id, on, runModel, speed, temp);
    }

    @Override
    public boolean optCentralAcIndoorUnit(int id, boolean on, String runModel, String speed, int temp) {
        if (smartHomeApi != null) {
            return smartHomeApi.asyncOptCentralAcGwIndoorUnit(id, on, runModel, speed, temp);
        }
        return false;
    }

    @Override
    public boolean openHueGateway(int gwId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.openHueGatewayChannel(gwId);
    }

    @Override
    public boolean activateHueGateway(int gwId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.activateHueGateway(gwId);
    }

    @Override
    public void updateHostArming(ArmingState state) {
        if (smartHomeApi != null)
            smartHomeApi.switchArmingState(state);
    }

    @Override
    public void switchRoomLights(int roomId, boolean on) {
        if (smartHomeApi != null)
            smartHomeApi.switchRoomLights(roomId, on);
    }

    @Override
    public void optRoomCurtains(int roomId, String operation) {
        if (smartHomeApi != null)
            smartHomeApi.optRoomCurtains(roomId, MotorOpt.valueOf(operation));
    }

    @Override
    public VoidResult adjustAlertorVolume(int id, int vol) {
        if (smartHomeApi != null) {
            return smartHomeApi.adjustAlertorVolume(id, vol);
        }
        return null;
    }

    @Override
    public void switchLight(int id, boolean on) {
        if (smartHomeApi != null)
            smartHomeApi.switchOpt(id, on);
    }

    @Override
    public VoidResult switchDevice(int devId, boolean on) {
        if (smartHomeApi == null) {
            return null;  //#13083 java.lang.NullPointerExceptio
        }
        return smartHomeApi.switchDevice(devId, on);
    }

    @Override
    public boolean adjustIllum(int devId, int bri) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.adjustDimmerIlum(devId, bri);
    }

    @Override
    public boolean adjustColor(int devId, int[] rgb) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.adjustDimmerColor(devId, rgb);
    }

    @Override
    public boolean adjustDimmerWhiteIlum(int id, int bri) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.adjustDimmerWhiteIlum(id, bri);
    }

    @Override
    public boolean adjustRgbwPickedColor(int id, int modeId, int[] rgb, int bri, int whiteBri) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.adjustRgbwPickedColor(id, modeId, rgb, bri, whiteBri);
    }

    @Override
    public VoidResult setDimmerRealIlum(int id, int bri) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setDimmerRealIlum(id, bri);
    }

    @Override
    public GetDimmableLightConfigResult getdimmableLightConfig(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getdimmableLightConfig(id);
    }

    @Override
    public VoidResult setDimmableLightConfig(int id, int softOn, int briLow, int briHigh) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setDimmableLightConfig(id, softOn, briLow, briHigh);
    }

    @Override
    public boolean adjustRgbwDymanicColor(int id, int modeId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.adjustRgbwDymanicColor(id, modeId);
    }

    @Override
    public JsonArray getDeviceAppArgs(int id, UniformDeviceType deviceType) {
        SHDeviceType type = null;
        if (deviceType != null) {
            type = SHDeviceType.parseValue(deviceType.name());
            if (type.equals(SHDeviceType.UNKOWN)) {
                type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
            }
        }
        if (smartHomeApi != null) {
            return smartHomeApi.getDeviceAppArgs(id, type);
        }
        return null;
    }

    @Override
    public boolean setDeviceAppArg(int id, UniformDeviceType deviceType, String argType, JsonElement arg) {
        if (smartHomeApi == null) {
            return false;
        }
        SHDeviceType type = null;
        if (deviceType != null) {
            type = SHDeviceType.parseValue(deviceType.name());
            if (type.equals(SHDeviceType.UNKOWN)) {
                type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
            }
        }
        return smartHomeApi.setDeviceAppArg(id, type, argType, arg);
    }
    @Override
    public boolean setDeviceCcuArg(int id, UniformDeviceType deviceType, String argType, JsonElement arg) {
        if (smartHomeApi == null) {
            return false;
        }
        SHDeviceType type = null;
        if (deviceType != null) {
            type = SHDeviceType.parseValue(deviceType.name());
            if (type.equals(SHDeviceType.UNKOWN)) {
                type = SHDeviceSubType.parseValue(deviceType.name()).getParentType();
            }
        }
        return smartHomeApi.setDeviceCcuArg(id, type, argType, arg);
    }


    @Override
    public void switchSocket(int devId, boolean on) {
        if (smartHomeApi != null) {
            smartHomeApi.switchOpt(devId, on);
        }
    }

    @Override
    public TextIndicatorResult getTextIndicatorStatus(int devId) {
        if (smartHomeApi != null) {
            return smartHomeApi.getTextIndicatorStatus(devId);
        }
        return null;
    }

    @Override
    public VoidResult setTextIndicatorArgs(int devId, int offTime) {
        if (smartHomeApi != null) {
            return smartHomeApi.setTextIndicatorArgs(devId, offTime);
        }
        return null;
    }

    @Override
    public boolean switchSocketChannel(int devId, int channel, boolean on) {
        if (smartHomeApi != null)
            return smartHomeApi.switchSocketChannel(devId, channel, on);
        return false;
    }

    @Override
    public boolean setSocketPowerConfig(int devId, String power, boolean powerOff, boolean powerRemember) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setSocketPowerConfig(devId, power, powerOff, powerRemember);
    }

    @Override
    public GetSocketRunArgsResult getSocketPowerConfig(int devId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getSocketPowerConfig(devId);
    }

    @Override
    public Boolean identify(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.identify(id);
    }

    @Override
    public Boolean closeAlertor(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.closeAlertor(id);
    }

    @Override
    public Boolean switchZigbeeKonkeLight(int devId, boolean on) {
        if (smartHomeApi != null)
            return smartHomeApi.zigbeekonkesocketOpt(devId, on);
        return false;
    }


    @Override
    public void switchKSocket(int devId, boolean on) {
        if (smartHomeApi != null)
            smartHomeApi.ksocketOpt(devId, on);
    }

    @Override
    public void switchKSocketUsb(int devId, boolean on) {
        if (smartHomeApi != null)
            smartHomeApi.ksocketUsbOpt(devId, on);
    }

    @Override
    public void switchKSocketLight(int devId, boolean on) {
        if (smartHomeApi != null)
            smartHomeApi.ksocketLightOpt(devId, on);
    }

    @Override
    public boolean switchKLock(int devId, String password, boolean on) {
        if (smartHomeApi != null)
            return smartHomeApi.klockOpt(devId, password, on);
        return false;
    }

    @Override
    public VoidResult swithCodedLock(int devId, String password, boolean on) {
        if (smartHomeApi != null)
            return smartHomeApi.codedLockOpt(devId, password, on);
        return null;
    }

    @Override
    public void executeScene(int sceneId) {
        if (smartHomeApi != null)
            smartHomeApi.sceneOpt(sceneId);
    }

    @Override
    public void operateMotor(int devId, String operation) {
        if (smartHomeApi != null) {
            smartHomeApi.motorOpt(devId, operation);
        }
    }

    @Override
    public boolean dooyaMotorSeek(int devId, int pos) {
        if (smartHomeApi != null) {
            return smartHomeApi.dooyaSeek(devId, pos);
        }
        return false;
    }

    @Override
    public boolean dooyMotorRouteCfg(int devId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.dooyaRouteCfg(devId);
    }

    @Override
    public boolean dooyaSetReverse(int devId, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setDooyaReverse(devId, on);
    }

    @Override
    public boolean dooyaGetReverse(int devId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.getDooyaReverse(devId);

    }

    @Override
    public VoidResult motorSmartConfig(int devId, String cmd, String cmdArg) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setMotorSmartConfig(devId, cmd, cmdArg);
    }

    @Override
    public VoidResult driveAirerLightOpt(int id, boolean on) {
        if (smartHomeApi != null) {
            return smartHomeApi.driveAirerLightOpt(id, on);
        }
        return null;
    }

    @Override
    public VoidResult driveAirerMotorOpt(int id, MotorOpt opt) {
        if (smartHomeApi != null)
            return smartHomeApi.driveAirerMotorOpt(id, opt);
        return null;
    }

    @Override
    public VoidResult driveAirerAirDryOpt(int id, boolean on, int timeInMinutes) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.driveAirerAirDryOpt(id, on, timeInMinutes);
    }

    @Override
    public VoidResult driveAirerStovingOpt(int id, boolean on, int timeInMinutes) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.driveAirerStovingOpt(id, on, timeInMinutes);
    }

    @Override
    public VoidResult driveAirerSterilizeOpt(int id, boolean on, int timeInMinutes) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.driveAirerSterilizeOpt(id, on, timeInMinutes);
    }

    @Override
    public VoidResult setFloorHeatingTemp(int id, double temp) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorHeatingTemp(id, temp);
    }

    @Override
    public VoidResult setFloorHeatingTemp(int id, int temp) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorHeatingTemp(id, temp);
    }


    @Override
    public VoidResult setFloorHeatingMode(int id, boolean autoElseManual) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorHeatingMode(id, autoElseManual);
    }

    @Override
    public VoidResult setFloorHeatingPlan(int id, List<ZigbeeFloorHeatingStatus.SettingZone> zoneList) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorHeatingPlan(id, zoneList);
    }

    @Override
    public boolean isFloorHeatingSingleDayOff(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.isFloorHeatingSingleDayOff(id);
    }

    @Override
    public VoidResult setFloorheatingOffTime(int id, String offTime) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorheatingOffTime(id, offTime);
    }

    @Override
    public VoidResult setFloorheatingLockStatus(int id, boolean lock) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorheatingLockStatus(id, lock);
    }

    @Override
    public FloorheatingConfigArgResult getFloorheatingConfigArgs(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getFloorheatingConfigArg(id);
    }

    @Override
    public VoidResult setFloorhearManagerOpt(int id, int[] channal, boolean on) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorhearManagerOpt(id, channal, on);
    }

    @Override
    public GetFloorheatingStatusResult getFloorheatDevStatu(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getFloorheatDevStatu(id);
    }

    @Override
    public VoidResult setFloorheatingDevTemp(int id, double temp) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorheatingDevTemp(id, temp);
    }

    @Override
    public VoidResult setFlootheatingDevLock(int id, boolean lock) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFloorheatingDevLock(id, lock);
    }

    @Override
    public boolean freshAirSwitch(int id, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.freshAirSwitch(id, on);
    }

    @Override
    public boolean freshAirSetRunModel(int id, ZigbeeFreshAirStatus.RUNMODEL runModel) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.freshAirSetRunModel(id, runModel);
    }

    @Override
    public boolean freshAirSetWorkModel(int id, ZigbeeFreshAirStatus.WORKMODEL workModel) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.freshAirSetWorkModel(id, workModel);
    }

    @Override
    public boolean freshAirSetSpeed(int id, ZigbeeFreshAirStatus.SPEEDLELVEL speed) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.freshAirSetSpeed(id, speed);
    }

    @Override
    public String freshAirGetCo2(int id) {
        return smartHomeApi.freshAirGetCo2(id);
    }

    @Override
    public String freshAirGetPm25(int id) {
        return smartHomeApi.freshAirGetPm25(id);
    }

    @Override
    public boolean freshAirSetFilterScreenWorkTime(int id, int timeIn100h) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.freshAirSetFilterScreenWorkTime(id, timeIn100h);
    }

    @Override
    public boolean freshAirResetFilterScreen(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.freshAirResetFilterScreen(id);
    }

    @Override
    public VoidResult freshAirSetLockStatus(int id, boolean lock) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.freshAirSetLockStatus(id, lock);
    }

    @Override
    public ChopinFreshAirConfigArgsResult getChopinFreshAirConfigArgs(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getChopinFreshAirConfigArgs(id);
    }

    @Override
    public VoidResult setFreshAirOffTime(int id, String timeOff) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFreshAirOffTime(id, timeOff);
    }

    @Override
    public VoidResult setChopinFreshAitAlarmTime(int id, boolean reset, int alarmTime) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFreshAitFilterAlarmTime(id, reset, alarmTime);
    }

    @Override
    public GetFreshAirStatusResult getFreshAirDevStatus(int devId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getFreshAirStatus(devId);
    }

    @Override
    public VoidResult setFreshAirDevSpeed(int devId, int speed) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFreshAirDevSpeed(devId, speed);
    }

    @Override
    public VoidResult setFreshAirDevMode(int devId, int mode) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFreshAirDevMode(devId, mode);
    }

    @Override
    public VoidResult resetFreshAirDevFilterTime(int devId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.resetFreshAirDevFilterTime(devId);
    }

    @Override
    public VoidResult setFreshAitDevFilterAlarmTime(int devId, int time) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setFreshAirDevFilterAlarmTime(devId, time);
    }

    @Override
    public void operateHue(int devId, boolean on, int bri, double[] xy) {
        if (smartHomeApi != null)
            smartHomeApi.hueOpt(devId, on, bri, xy);
    }

    @Override
    public void operateKLight(int devId, String mode, boolean on, int bri, int[] rgb, int speed) {
        if (smartHomeApi != null)
            smartHomeApi.klightOpt(devId, mode, on, bri, rgb, speed);
    }

    @Override
    public void operateInfrared(int devId, int code) {
        if (smartHomeApi != null)
            smartHomeApi.infraredOpt(devId, code);
    }

    @Override
    public boolean sendInfrared(int devId, int code) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.sendInfrared(devId, code);
    }

    @Override
    public void learnInfrared(int id, int code) {
        if (smartHomeApi != null)
            smartHomeApi.asyncLearnInfrared(id, code);
    }

    @Override
    public boolean saveInfrared(int id, int code) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.saveInfrared(id, code);
    }

    @Override
    public boolean saveInfraredRC(int id, List<Controller.Button> buttons) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.saveInfraredRC(id, buttons);
    }

    @Override
    public boolean operateRF(int devId, int code) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.rfOpt(devId, code);
    }

    @Override
    public void learnRF(int id, int code) {
        if (smartHomeApi != null)
            smartHomeApi.asyncLearnRF(id, code);
    }

    @Override
    public boolean saveRF(int id, int code) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.saveRF(id, code);
    }

    @Override
    public boolean saveRFRC(int id, List<Controller.Button> buttons) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.saveRFRC(id, buttons);
    }

    @Override
    public GetDevDetectedPowerResult getDevDetectPowerResult(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getDevDetectPowerResult(id);
    }

    @Override
    public boolean setDevDetectPowerByHand(int id, String standby, String running) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setDevDetectPowerByHand(id, standby, running);
    }

    @Override
    public boolean activeDevDetectPower(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.activeDevDetectPower(id);
    }

    @Override
    public void detectDevStandByPower(int id) {
        if (smartHomeApi != null)
            smartHomeApi.detectDevStandByPower(id);
    }

    @Override
    public void detectDevRunningPower(int id) {
        if (smartHomeApi != null)
            smartHomeApi.detectDevRunningPower(id);
    }

    @Override
    public void controllerSmartSwitch(int id, boolean on) {
        if (smartHomeApi != null)
            smartHomeApi.controllerSmartSwitch(id, on);
    }

    @Override
    public GetCodelibResult getInfraredBindCodelib(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getInfraredBindCodelib(id);
    }

    @Override
    public CodeLibBaseResult renameLocalCodelib(int codeId, String codelibName) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.renameLocalCodelib(codeId, codelibName);
    }

    @Override
    public void resetInfraredBindCodelib(int id) {
        if (smartHomeApi != null)
            smartHomeApi.asynResetInfraredBindCodelib(id);
    }

    @Override
    public CodeLibBaseResult uploadCodelibToCloud(int codelibId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.uploadCodelibToCloud(codelibId);
    }

    @Override
    public GetLocalCodelibsResult getInfraredCodelib(String devType) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getInfraredCodelib(devType);
    }

    @Override
    public CodeLibBindResult getCodelibBindInfrareds(int libId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getCodelibBindInfrareds(libId);
    }

    @Override
    public CodeLibBaseResult deleteInfraredCodelib(int libId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.deleteInfraredCodelib(libId);
    }

    @Override
    public AddCodeLibResult addInfraredCodelib(int devId, String devType, String libName, String codeLibLocation) {
        if (smartHomeApi != null) {
           return smartHomeApi.addInfraredCodelib(devId, devType, libName, codeLibLocation);
        }
        return null;
    }

    @Override
    public CodeLibBaseResult testInfraredCodelib(int devId, int libId, int code) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.testInfraredCodelib(devId, libId, code);
    }

    @Override
    public CodeLibBaseResult testCloudCodelib(int devId, int cloudLibId, int code) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.testCloudCodelib(devId, cloudLibId, code);
    }

    @Override
    public CodeLibBaseResult prepareTestCloudCodeLib(int cloudLibId) {
        if (smartHomeApi == null) {
            return null;
        }
       return smartHomeApi.prepareTestCloudlib( cloudLibId);
    }

    @Override
    public PrepareTestCodeLibResult downloadCodeLibFromCloud(int cloudLibId, int type, String devType, String devBound, String devModel, String name, String pcode) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.downloadCodeFromCloud( cloudLibId, type, devType, devBound, devModel, name, pcode);
    }

    @Override
    public void matchInfraredCodelib(int libId, String devType) {
        if (smartHomeApi != null)
            smartHomeApi.matchInfraredCodelib(libId, devType);
    }

    @Override
    public CodeLibTaskResult getCodelibWorkingTask() {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getCodelibWorkingTask();
    }

    @Override
    public GetCodelibButtonsResult getCodelibUiButtons(int libId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getCodelibUiButtons(libId);
    }

    @Override
    public void uploadCodelib(int id, int libId) {
        if (smartHomeApi != null)
            smartHomeApi.asynUploadCodelib(id, libId);
    }

    @Override
    public boolean bindLockDoorcontact(int id, int doorcontactId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.bindLockWithDoorcontact(id, doorcontactId);
    }

    @Override
    public boolean bindInfraredSocket(int id, int socketId) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.asyncBindInfraredSocket(id, socketId);
    }

    @Override
    public boolean musicControllerPlayPause(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.musicControllerPlayPause(id);
    }

    @Override
    public boolean musicControllerPlayPre(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.musicControllerPlayPre(id);
    }

    @Override
    public boolean musicControllerPlayNext(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.musicControllerPlayNext(id);
    }

    @Override
    public boolean musicControllerPlayInMusicList(int id, int musicIndex) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.musicControllerPlayInMusicList(id, musicIndex);
    }

    @Override
    public boolean musicControllerPlaySeek(int id, int seekTimeInMs) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.musicControllerPlaySeek(id, seekTimeInMs);
    }

    @Override
    public boolean setMusicControllerVolume(int id, int volume) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setMusicControllerVolume(id, volume);
    }

    @Override
    public boolean setMusicControllerZoneVolume(int id, int zoneId, int zoneVolume, boolean volSwitch) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setMusicControllerZoneVolume(id, zoneId, zoneVolume, volSwitch);
    }

    @Override
    public boolean setMusicControllerZoneName(int id, int zoneId, String name) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setMusicControllerZoneName(id, zoneId, name);
    }

    @Override
    public boolean changeMusicControllerLoopMode(int id) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.changeMusicControllerLoopMode(id);
    }

    @Override
    public boolean enbaleMusicControllerEQ(int id, boolean enable) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.enbaleMusicControllerEQ(id, enable);
    }

    @Override
    public boolean setMusicControllerEqMode(int id, String mode) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setMusicControllerEqMode(id, mode);
    }

    @Override
    public List<GetYouzhuanMusicListResult.MusicListBean> queryYouzhuanMusicList(int id, String arg) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.queryYouzhuanMusicList(id, arg);
    }

    @Override
    public VoidResult setYouzhuanMusicPlay(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouzhuanMusicPlay(id);
    }

    @Override
    public VoidResult setYouzhuanMusicPause(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouzhuanMusicPause(id);
    }

    @Override
    public VoidResult playYouzhuanMusicPre(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.playYouzhuanMusicPre(id);
    }

    @Override
    public VoidResult playYouzhuanMusicNext(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.playYouzhuanMusicNext(id);
    }

    @Override
    public VoidResult playYouzhuanMusicByIndex(int id, int index) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.playYouzhuanMusicByIndex(id, index);
    }

    @Override
    public VoidResult setYouzhuanMusicSeek(int id, int pos) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouzhuanMusicSeek(id, pos);
    }

    @Override
    public VoidResult setYouzhuanMusicVol(int id, int vol) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouzhuanMusicVol(id, vol);
    }

    @Override
    public VoidResult setYOuzhuanMusicLoopModel(int id, int model) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouzhuanMusicLoopModel(id, model);
    }

    @Override
    public VoidResult setYouzhuanMusicEq(int id, int eq) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouzhuanMusicEq(id, eq);
    }

    @Override
    public VoidResult setYouhzuanMusicSource(int id, int source) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setYouhzuanMusicSource(id, source);
    }

    @Override
    public VoidResult startSearchYouzhuanMusic() {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.startSearchYouzhuanMusic();
    }

    @Override
    public VoidResult stopSearchYouzhuanMusic() {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.stopSearchYouzhuanMusic();
    }

    @Override
    public Device editYouzhuanMusic(int id, String name, int roomId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.editYouzhuanMusic(id, name, roomId);
    }

    @Override
    public VoidResult delYouzhuanMusic(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.delYouzhuanMusic(id);
    }

    @Override
    public boolean setHumidifierFogVol(int devId, int vol) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setHumidifierFogVol(devId, vol);
    }

    @Override
    public boolean setHumidifierOnOff(int devId, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setHumidifierOnOff(devId, on);
    }

    @Override
    public boolean setHumidifierConstantWet(int devId, boolean on, int vol) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setHumidifierConstantWet(devId, on, vol);
    }

    @Override
    public boolean setAircleanrWindVol(int devId, int vol) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setAircleanrWindVol(devId, vol);
    }

    @Override
    public boolean setAircleanrOnOff(int devId, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setAircleanrOnOff(devId, on);
    }

    @Override
    public boolean setAircleanrAnionOnOff(int devId, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setAircleanrAnionOnOff(devId, on);
    }

    @Override
    public boolean setAircleanrSleepOnOff(int devId, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setAircleanrSleepOnOff(devId, on);

    }

    @Override
    public boolean setAircleanrAutoOnOff(int devId, boolean on) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.setAircleanrAutoOnOff(devId, on);
    }

    @Override
    public VoidResult setFancoilSmartModel(int id, FancoilSmartModel SmartModel) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetSmartModel(id, SmartModel);
    }

    @Override
    public VoidResult setFancoilSmartModel(int id, int modelId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetSmartModel(id, modelId);
    }

    @Override
    public VoidResult setFancoilDelay(int id, boolean onEnable, String onDelayTime, boolean offEnable, String onOffDelayTime) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetDelaytask(id, onEnable, onDelayTime, offEnable, onOffDelayTime);
    }

    @Override
    public VoidResult setFancoilTemp(int id, String temp) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetRunTemp(id, temp);
    }

    @Override
    public VoidResult setFancoilSpeed(int id, ZigbeeFanCoilStatus.FANSPEED fanspeed) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetFanSpeed(id, fanspeed);
    }

    @Override
    public VoidResult setFancoilRunModel(int id, ZigbeeFanCoilStatus.RUNMODEL runmodel) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetRunModel(id, runmodel);
    }

    @Override
    public GetFancoilSmartModelResult getFancoilSmartModel(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilGetSmartModel(id);
    }

    @Override
    public boolean saveFancoilCustomSmartModel(int id, FancoilSmartModel model) {
        if (smartHomeApi == null) {
            return false;
        }
        return smartHomeApi.saveFancoilCustomSmartModel(id, model);
    }

    @Override
    public FancoilSmartModel getFancoilCustomSmartModel(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getFancoilCustomSmartModel(id);
    }

    @Override
    public GetFancoilSystemStatusResult fancoilGetSystemStatus(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilGetSystemStatus(id);
    }

    @Override
    public VoidResult fancoilSetLocking(int id, String locking) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetLocking(id, locking);
    }

    @Override
    public VoidResult fancoilSetLockStatus(int id, boolean lock) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.fancoilSetLockStatus(id, lock);
    }

    @Override
    public FancoilConfigArgsResult getFancoilConfigArgs(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getFancoilConfigArgs(id);
    }

    @Override
    public GetElectricalEnergyValueResult getElectricalEnergyValues(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getElectricalEnergyValues(id);
    }

    @Override
    public GetElectricalEnergyArgsResult getElectricalEnergyArgs(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getElectricalEnergyArgs(id);
    }

    @Override
    public GetElectricalClearingInfoResult getElectricalClearningInfoResult(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getElectricalClearningInfoResult(id);
    }

    @Override
    public GetElectricalClearingDateResult getElectricalClearningDateResult(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getElectricalClearningDateResult(id);
    }

    @Override
    public GetElectricalSwitchStatusResult getElectricalSwitchStatus(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getElectricalSwitchStatus(id);
    }

    @Override
    public VoidResult setElectricalSwitch(int id, boolean on) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setElectricalSwitch(id, on);
    }

    @Override
    public VoidResult editCodedLockUser(int id, int userId, int openType, boolean hijack, boolean permission, String key, int openTimes, String startTime, String endTime) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.editCodedLockUser(id, userId, openType, hijack, permission, key, openTimes, startTime, endTime);
    }

    @Override
    public GetCodedLockUserInfoResult getCodedLockUser(int id, int userId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getCodedLockUser(id, userId);
    }

    @Override
    public AddCodedLockUserResult addCodedLockUser(int id, int openType, boolean permission, boolean hijack, String key) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.addCodedLockUser(id, openType, permission, hijack, key);
    }

    @Override
    public VoidResult delCodedLockUser(int id, int[] userId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.delCodedLockUser(id, userId);
    }

    @Override
    public VoidResult delCodedLockAllUser(int id) {
        return smartHomeApi.delCodedLockAllUser(id);
    }

    @Override
    public VoidResult codedlockEnterCardmode(int id, boolean encrypt) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.codedlockEnterCardmode(id, encrypt);
    }

    @Override
    public VoidResult clearAirSwitchAlarm(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.clearAirSwitchAlarm(id);
    }

    @Override
    public GetAirSwitchStatusResult getAirSwitchStatus(int id) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getAirSwitchStatus(id);
    }

    @Override
    public VoidResult addAirBox(String mac, String type) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.addAirBox(mac,type);
    }

    @Override
    public Device setAirBox(int devId, String name, int roomId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.setAirBox(devId, name, roomId);
    }

    @Override
    public GetAirBoxStateResult getAirBoxStete(int devId, int arg) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getAirBoxStete(devId, arg);
    }

    @Override
    public GetAirBoxDayStatisitcResult getAirBoxDayStatisitc(int devId, String field, String start, String end) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getAirBoxDayStatisitc(devId, field, start, end);
    }

    @Override
    public AirBoxNodeArgResult getAirboxNodeArg(int devId) {
        if (smartHomeApi == null) {
            return null;
        }
        return smartHomeApi.getAirboxNodeArg(devId);
    }

    @Override
    public void resetTimeInterval() {
        if (smartHomeApi != null)
            smartHomeApi.resetTimeInterval();
    }

    @Override
    public void destroy() {
        if (smartHomeApi != null)
            smartHomeApi.destroy();
        smartHomeApi = null;
    }
}
